package tomkitty.server;

import tomkitty.turdlet.*;
import tomkitty.util.*;
import java.util.*;

/**
 *
 * Main HTTP server class. Entry point of the server.
 *
 * Based on the example:
 * http://java.sun.com/developer/technicalArticles/Networking/Webserver/
 *
 * @author alan, micha
 *
 */
public class Main {
    
		private static Configuration conf;
		private Hashtable<Object, Object> registeredData;

    /** Creates a new instance of Main */
    public Main() {
			conf = new Configuration();

			conf.set("port", "8080");
			conf.set("minthreads", "10");
			conf.set("maxthreads", "100");
			conf.set("default_turdlet", "Index");
			conf.set("docroot", "/tmp");

			registeredData = new Hashtable<Object, Object>();
			
			Server ss = new Server(toInt(conf.get("port")), 
					toInt(conf.get("minthreads")), toInt(conf.get("maxthreads")));
    }

		private int toInt(String s) {
			return new Integer(s).intValue();
		}

		public static Configuration getConfig() {
			return conf;
		}

    /**
     * Convenience stdout wrapper
     * @param s The String to print to stdout
     */
    protected static void p(String s) {
        System.out.println(s);
    }
    
    /**
     * Instantiate and kick things off.
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new Main();
    }
}
